package com.bweab.controll.userstbcontrol;

import com.bweab.service.api.UsersTbServiceInterface;
import com.bweab.service.impl.UsersTbServiceInterfaceImpl;
import com.bweab.util.JSONResult;
import com.bweab.util.WebUtil;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
@WebServlet("/adminAddUser")
public class AdminAddUser extends HttpServlet {
    //创建服务
    UsersTbServiceInterface usersTbService=new UsersTbServiceInterfaceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取用户信息

        //获取用户名
        String username = req.getParameter("username");
        //获取密码
        String userpassword = req.getParameter("userPassword");
        //获取性别
        String userSex = req.getParameter("userSex");
        //获取学号
        String userXh = req.getParameter("userXh");
        //获取手机号
        String userPhone = req.getParameter("userPhone");
        //获取用户身份状态
        String userStatus = req.getParameter("userStatus");
        System.out.println(username+"\n"+userpassword+"\n"+userSex+"\n"+userXh+"\n"+userPhone);
        System.out.println(userSex);

        //调用管理员增加服务
        JSONResult jsonResult= usersTbService.adminAddUser(username,userPhone,userStatus,userXh,userSex,userpassword);

        WebUtil.writeJson(resp,jsonResult);

    }
}
